//index.js
var app = getApp();
Page({
  data:{
      userInfo: {},
      animationData: {}
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数

  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
      var animation = wx.createAnimation({
          duration: 500,
          timingFunction: 'ease-in'
      });

      this.animation = animation;

      animation.opacity(1).step();

      this.setData({
          animationData:animation.export()
      });
      var that = this;
      wx.getUserInfo({
          success: function (res) {
              that.setData({
                  userInfo: res.userInfo
              });
          }
      });
  },
    goToCollection: function () {
        wx.navigateTo({ url: '/pages/my/collection/index' });
    },
    goToBrowse: function () {
        wx.navigateTo({ url: '/pages/my/browse/index' });
    },
    goToComment: function () {
        wx.navigateTo({ url: '/pages/my/comment/index' });
    },
    goToThumbsup: function () {
        wx.navigateTo({ url: '/pages/my/thumbsup/index' });
    },
    gotoMyComplaints: function (event) {
        var goodsId =event.currentTarget.dataset.goodsid;
        wx.navigateTo({ url: '/pages/my/complaints/index?Id='+ goodsId +'' });
    },
    deleteSkimItem: function(event){
        var that = this;
        var goodsId =event.currentTarget.dataset.goodsid;
        wx.showModal({
            title: '提示',
            content: '是否删除浏览记录？',
            success: function(res) {
                if (res.confirm) {
                    app.doRequest('my_DeleteBrowseRecord', {
                        goodsId: goodsId
                    }, function (data) {
                        that.loadData();
                    })
                }
            }
        })


    },
    deleteAllSkimItem: function(event){
        var that = this;
        wx.showModal({
            title: '提示',
            content: '是否清空浏览记录？',
            success: function(res) {
                if (res.confirm) {
                    app.doRequest('my_CleanBrowseRecord', {
                    }, function (data) {
                        that.loadData();
                    })
                }
            }
        })
    }
})